package com.ac.app.web.action.pick;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.caac.core.web.action.BaseAction;
import com.caac.core.web.form.BaseForm;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright AgileCentury 2008</p>
 * <p>Company: AgileCentury </p>
 * @author <a href="mailto:ac@agilecentury.com">Agile</a>
 * @version 1.0
 */

public class SubPkRecordAction extends BaseAction {
    protected ActionForward doExecute(ActionMapping mapping,
                                      BaseForm form,
                                      HttpServletRequest request,
                                      HttpServletResponse response)
            throws Exception {
        String[] ids = request.getParameterValues("id");
        String[] subs = request.getParameterValues("subs");
        if (subs != null) {
            String sub = "";
            for (int i = 0; i < subs.length; i++) {
                sub = sub + subs[i] + ",";
            }
            for (int i = 0; i < ids.length; i++) {
                this.getJdbcTemplate().update(
                        "UPDATE PICK_RECORD SET STATE='1',SUB_NAME='" + sub
                                + "' WHERE ID='" + ids[i] + "'");
            }
        }

        return forward(mapping);
    }
}
